const express = require('express');
const crypto = require('crypto')
const mongo = require('../db/mongo')
const router = express.Router();
const hash = crypto.createHash('sha256');


router.get('/login', async (req, res) => {
    let { username, password } = req.query;
    // hash.update(password + 'fbsfbaetemlka');
    // password = hash.digest('hex')
    var data = await mongo.find('user', {})

    if (username === data[0].username && password === data[0].password) {
        res.send({
            data: { username, password },
            code: 200,
            msg: '登录成功',
        })
    } else {
        res.send({
            data: {},
            code: 400,
            msg: '用户名或密码错误'
        })
    }

})
module.exports = router;

